import pagination from '@/views/pagination'  //分页组件
import Popup from './edit' //弹窗组件
import agentHttp from '@/utils/agentHttp.js';
import {
  debounce,
  timestampToTime,
  initDataTime
} from '@/utils/index.js'
export default {
  name: 'priceAudit',
  created() {
    this.seachData()
  },
  components: {
    Popup,pagination
  },
  data() {
    return {
      //搜索字段
      searchForm: {
        dealerName: "",
        priceStatus: "",
        orderNumber: "",
        startDate: "",
        endDate: "",
      }, 
      //表格字段
      tableData: {},
      orderId:null,
      formLabelWidth: '120px',
      statusMap: '',
      //发送给弹窗的数据
      dialogSendData: {
        isAdd: true, //是否为编辑或者新增  true是   false否
        dialogFormVisible: false, //弹窗是否显示        true是   false否
        id: "" //请求参数            自定义 例如index或者id
      },
      startDateOpt: {
        disabledDate(time) {
          return time.getTime() > Date.now()
        }
      },
      endDateOpt: {
        disabledDate: (time) => {
          return time.getTime() < new Date(this.searchForm.startDate).getTime();
        }
      },

      resetFormStatus: false

    }
  },

  methods: {
    seachData() {
      if (!this.resetFormStatus) {
        // var params = this.searchForm || {};
        var params = initDataTime(this.searchForm)
        params.page = this.tableData.page || 1;
        params.rows = this.tableData.rows || 10;
        agentHttp.PostModel('adminApi/admin/mortgage_contractinfo/get_tobe_added_mortgage_contract_order', params).then((data) => {
          if (data.success) {
            this.tableData = data.data
            
            // this.userType = data.data.userType;
          }
        })
      }
    },
    formIsEdit(e) { //点击按钮
      this.dialogSendData.dialogFormVisible = true;
      this.dialogSendData.isAdd = false;
      const id = e.currentTarget.dataset.id ;
      
      this.orderId = id
    },
    getDate(time){
      return timestampToTime(time)
    },
    debounceSeach(){      //input框内容发生改变时，调接口显示查询结果
      this.tableData.page=1;
      debounce(this.seachData(this.searchForm),1000)
    },
    resetSearchForm(formName){
      this.$refs[formName].resetFields();
      this.seachData()
    }

  }
}
